Imports System.Xml.Serialization
Imports DotNetNuke.UI.WebControls
Imports System.ComponentModel
Imports Aricie.DNN.UI.Attributes
Imports Aricie.DNN.Configuration
Imports Aricie.DNN.Caching.Analysis.Graphs

Namespace Aricie.DNN.Caching

    Public Class DistributedCachingConfigUpdate
        Implements IUpdateProvider



        Public Function GetConfigElements() As System.Collections.Generic.List(Of Configuration.IConfigElementInfo) Implements Configuration.IUpdateProvider.GetConfigElements
            Dim toReturn As New List(Of IConfigElementInfo)
            Dim dnn5 As Boolean = Aricie.DNN.Services.NukeHelper.DnnVersion.Major > 4
            If dnn5 Then
                toReturn.Add(New ProviderInfo("caching", "Aricie.DistributedCachingProvider", _
                                    Aricie.Services.ReflectionHelper.CreateType("Aricie.DNN.Caching.DistributedCachingProvider5, Aricie.DNN.DistributedCachingProvider.DNN5Adapter"), "FileBasedCachingProvider"))
            Else
                toReturn.Add(New ProviderInfo("caching", "Aricie.DistributedCachingProvider", GetType(DistributedCachingProvider4), "FileBasedCachingProvider"))
            End If

            toReturn.Add(New HttpHandlerInfo("Aricie.CacheGraphImageHandler", GetType(CacheGraphImageHandler), "GraphImage.ashx", "GET,HEAD", "integratedMode"))
            Dim toAdd As New HttpModuleInfo("Aricie.DistributedCachingModule", GetType(DistributedCachingModule), "managedHandler")

            toAdd.InsertBeforeKey = "ScriptModule"
            'There is nologer key "ScriptModule" in dnn7
            '13.03.2013 
            If Aricie.DNN.Services.NukeHelper.DnnVersion.Major >= 7 Then
                toAdd.InsertBeforeKey = "RequestFilter"


            End If


            toReturn.Add(toAdd)
            Return toReturn
        End Function

    End Class
End Namespace